package com.pro.control;

import com.pro.entity.Course;
import com.pro.entity.CourseOrderPlus;
import com.pro.entity.JsonData;
import com.pro.service.CourseOrderService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.List;

/**
 * @author ：刘弘禹
 * @description：TODO
 * @date ：2021/11/14 19:27
 */
@Controller
@RequestMapping("/CourseOrder")
public class CourseOrderController {
    @Autowired
    private CourseOrderService courseOrderService;

    @RequestMapping("/queryCourse")
    @ResponseBody
    public JsonData queryCourse(CourseOrderPlus courseOrderPlus){
        List<CourseOrderPlus> courseOrderPluses = courseOrderService.queryCourse(courseOrderPlus);
        return courseOrderPluses!=null?JsonData.buildSuccess(courseOrderPluses):JsonData.buildError("服务器错误");
    }

    @RequestMapping("/getCourse")
    @ResponseBody
    public JsonData getCourse(Integer id){
        System.err.println(id);
        Course course = courseOrderService.getCourse(id);
        System.err.println(course);
        return course!=null?JsonData.buildSuccess(course):JsonData.buildError("服务器错误");
    }
}
